﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace BestCode.Creds.Test
{
    [TestClass]
    public class EmailSenderTest
    {
        [TestMethod]
        public void TestMethod1()
        {
            string AdminEmail = "admin@bestcodebo.com";
            var mailMessage = new System.Net.Mail.MailMessage(AdminEmail, "jhoncacru@gmail.com");
            mailMessage.Subject = "Subject";
            mailMessage.Body = "<h1>This is test message from BESTCODE</h1>";
            mailMessage.IsBodyHtml = true;
            GetSmtpClient().Send(mailMessage);

        }

        public static System.Net.Mail.SmtpClient GetSmtpClient()
        {
            SmtpSettings config = new SmtpSettings();
            config.HostName = "smtp.bestcodebo.com";
            config.DefaultUserName = "admin@bestcodebo.com";
            config.DefaultUserPassword = "Jhonypapi1";
            config.IsSSLEnabled = false;

            var smtpClient = new System.Net.Mail.SmtpClient();
            smtpClient.Host = config.HostName;
            smtpClient.Credentials = new System.Net.NetworkCredential(config.DefaultUserName, config.DefaultUserPassword);
            smtpClient.EnableSsl = config.IsSSLEnabled;
            return smtpClient;
        }


        public class SmtpSettings
        {
            public string HostName { get; set; }
            public string DefaultUserName { get; set; }
            public string DefaultUserPassword { get; set; }
            public bool IsSSLEnabled { get; set; }

        }

    }
}
